$(function(){

    var id = location.search.slice(1).split("=")[1].split("&")[0]
    var title = location.search.slice(1).split("=")[2];
    // console.log(id);
    // console.log(title);
    
  
    $.ajax({
        type: "get",
        url: "http://193.112.55.79:9090/api/getcategorybyid",
        data: {
            categoryid :id
        },
        dataType: "json",
        success: function (res) {
            // console.log(res);
            var html = template("titletp",res)
            $('.fl').after(html)
        }
    });
    
    $.ajax({
        type: "get",
        url: "http://193.112.55.79:9090/api/getproductlist",
        data: {
            categoryid :id
        },
        dataType: "json",
        success: function (res) {
            console.log(res);
            var html1= template("listtp",res)
            $('.product-list').html(html1)
        }
    });

    // 获取头部盒子
    var headerbox = document.querySelector('.mmb_header')
    // 获取小点点
    var topbox = document.querySelector(".to-top")
    // 获取头部盒子的高度
    var headerH = headerbox.offsetHeight
    console.log(headerH);
    window.onscroll=function(){
        var movertop = document.body.scrollTop + document.documentElement.scrollTop;
        if(movertop >headerH){
            topbox.style.display="block"
        }else{
            topbox.style.display="none"

        }
        topbox.onclick=function(){
            console.log(movertop);
            document.documentElement.scrollTop = 0+"px"
            
        }
        
    }
    
    



})